<?php
/**
 * Created by yuxianjun.
 * User: yuxianjun
 * Date: 2018/4/27
 * Time: 14:46
 */

namespace App\admin\controller;


use Common\controller\Controller;
use Curl\Curl;

class CurlTest extends Controller
{
    public function index(){
        $curl=new Curl();
        $curl->setBasicAuthentication('username', 'password');
        $curl->setUserAgent('');
        $curl->setReferrer('');
        $curl->setHeader('X-Requested-With', 'XMLHttpRequest');
        $curl->setCookie('key', 'value');
        $curl->get('http://www.example.com/');

        if ($curl->error) {
            echo $curl->error_code;
        }
        else {
            echo $curl->response;
        }

        var_dump($curl->request_headers);
        var_dump($curl->response_headers);

    }

}